<!--
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
*
 ********************************************************************************/
-->


<table class="dvtContentSpace" border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr><td valign="top">&nbsp;</td>
	</tr>
	<tr>
		<td align="right" valign="top">
			<form name="Submit" method="POST" action="index.php">
				<input type=hidden name="fun" value="search">
				<input type=hidden name="module" value="Faq">
				<input type=hidden name="action" value="index">
				<input type="text" name="search_text" value=" <?php require_once('include/utils/utils.php'); echo portal_purify($search_text);?>">&nbsp;in&nbsp;
				<?php echo getSearchCombo(); ?>
				<input class= "crmbutton small cancel" type="submit" name="search" onclick="form.fun.value='search'" value="<?php echo getTranslatedString('LBL_SEARCH'); ?>">
			</form>
		</td>
   </tr>	
   <tr><td align="left" valign="top"><span class='lvtHeaderText'><?PHP echo getTranslatedString('LBL_KNOWLEDGE_BASE');?></span></td></tr>	
   <tr>
		<td align="left" valign="top">
			<table cellpadding="0" cellspacing="0" class="mainTab">
				<?PHP if(!empty($faq_array)){ ?>
				<tr>
					<td style="padding: 10px;width:20%;" valign="top">
						<?PHP if((count($category_array))>0 && $category_array !=null){ ?>
						<table class="lftMnu" border="0" width="100%" cellspacing="0" cellpadding="0">
				   			<tr>
								<td><a href="javascript:;toggleView('category')"><img id="categoryimg" src="images/minus.gif" border="0" align="absmiddle"></a></td>
								<td><a href="javascript:;toggleView('category')"><img src="images/category.gif" border="0" align="absmiddle"></a></td>
								<td><a href="javascript:;toggleView('category')" class="kbNavHead"><?php echo getTranslatedString('LNK_CATEGORY'); ?></a></td>
				   			</tr>
				   			<tr>
								<td></td>
								<td></td>
								<td>
									<div id="category" style="display:block">
									<table border="0" width="100%" cellspacing="0" cellpadding="0">
										<?php
											for($i=0,$j=1;$i<count($category_array);$i++,$j++){
							        			$noof_faqs = getNoofFaqsPerCategory($category_array[$i]);
												if(is_string($_REQUEST['category_index'])){
													$category_index = (int)$_REQUEST['category_index'];
												}
										?>
						   				<tr>
											<td nowrap><a class="hdr" href="index.php?module=Faq&action=index&fun=faqs&category_index=<?php echo $i; ?>">
												<?php 	if($category_index === $i)
															echo '<b>'.text_length($category_array[$i]).'</b>'; 
														else
															echo text_length($category_array[$i]);
												?>
												</a> <span class="hdr">
												<?php 	if($category_index === $i) 
															echo '<b>'.'('.$noof_faqs.')'.'</b>'; 
														else
															echo '('.$noof_faqs.')';
												?></span></td>
						   				</tr>
									<?php } ?>
									</table>
									</div>
								</td>
				   			</tr>
						</table>
						<?PHP } ?>
						<?PHP if($product_array != null) { ?>
						<table class="lftMnu" border="0" width="100%" cellspacing="0" cellpadding="0">
				   		<tr>
							<td><a href="javascript:;toggleView('products_array')"><img id="products_arrayimg" src="images/minus.gif" border="0" align="absmiddle"></a></td>
							<td><a href="javascript:;toggleView('products_array')"><img src="images/products.gif" border="0" align="absmiddle"></a></td>
							<td><a href="javascript:;toggleView('products_array')" class="kbNavHead"><?php echo getTranslatedString('LNK_PRODUCTS'); ?></a></td>
				  		 </tr>
				  		 <tr>
							<td></td>
							<td></td>
							<td>
								<div id="products_array" style="display:block">
								<table border="0" width="100%" cellspacing="0" cellpadding="0">
									<?php
									for($i=0,$j=1;$i<count($product_array);$i++,$j++) {
										$noof_faqs = getNoofFaqsPerProduct($product_array[$i]['productid']);
						   			?>
						   			<tr>
										<td nowrap>
											<a class="hdr" href="index.php?module=Faq&action=index&fun=faqs&productid=<?php echo $product_array[$i]['productid']; ?>">
											<?php 	if($_REQUEST['productid'] == $product_array[$i]['productid']) 
														echo '<b>'.$product_array[$i]['productname'].'</b>'; 
													else
														echo $product_array[$i]['productname'];
											?>
											</a> <span class="hdr">
											<?php 	if($_REQUEST['productid'] == $product_array[$i]['productid']) 
														echo '<b>'.'('.$noof_faqs.')'.'</b>'; 
													else 
														echo '('.$noof_faqs.')';
											?></span>
										</td>
						   			</tr>
									<?php } ?>
								</table>
								</div>
							</td>
				   		</tr>
					</table>
					<?PHP	} ?>
				</td>
				<td style="padding:10px;width:80%" valign="top">
			<?PHP } else { ?>
			<tr>
				<td>
					<?PHP echo getTranslatedString('LBL_KNOWLEDGE_BASE').' '.getTranslatedString('LBL_NOT_AVAILABLE');?>
				</td>
			</tr>
			</table>	
			<?PHP } ?>




<script language="JavaScript" src="js/cookies.js"></script>
<script>
function toggleView(view) {
	if(document.getElementById(view) != null){
		if (document.getElementById(view).style.display=="block") {
			document.getElementById(view).style.display="none"
			document.getElementById(view+"img").src="images/plus.gif"
			set_cookie("kb_"+view,"none")
		} else {
			document.getElementById(view).style.display="block"
			document.getElementById(view+"img").src="images/minus.gif"
			set_cookie("kb_"+view,"block")
		}
	}
}

var view=new Array("category","products_array")
for (i=0;i<view.length;i++) {
	if(document.getElementById(view) != null){
		if (get_cookie("kb_"+view[i])==null || get_cookie("kb_"+view[i])=="" || get_cookie("kb_"+view[i])=="block") {
			document.getElementById(view[i]).style.display="block"
			document.getElementById(view[i]+"img").src="images/minus.gif"
		} else {
			document.getElementById(view[i]).style.display="none"
			document.getElementById(view[i]+"img").src="images/plus.gif"
		}
	}
}
</script>
